package com.chzc.goods.controller.pub;


import com.chzc.po.User;
import com.chzc.util.Result;
import com.chzc.util.enums.KillEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundZSetOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author CV大魔王
 * @since 2021-05-27
 */
@Api(value = "下单排名", tags = "下单排名")
@RestController
@RequestMapping("/pub/order_info")
public class PubOrderInfoController {

    @Autowired
    private RedisTemplate redisTemplate;


    @ApiOperation("获取榜单前1000名")
    @GetMapping("/score/{goodsId}")
    public Result getScore(@PathVariable String goodsId) {
        BoundZSetOperations<String, User> operations = redisTemplate.boundZSetOps(KillEnum.goods_point_rank_real_ + goodsId);
        return Result.buildSuccess(operations.reverseRange(0, 1000));
    }

}
